<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"llmysnow.top","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="只要项目还在用，性能优化永远是时刻要关注的问题">
<meta property="og:type" content="article">
<meta property="og:title" content="优化1.性能优化的指标和工具">
<meta property="og:url" content="http://llmysnow.top/posts/8f9af1b2/index.html">
<meta property="og:site_name" content="奇幻的梦之旅">
<meta property="og:description" content="只要项目还在用，性能优化永远是时刻要关注的问题">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/NetworkQueue.png">
<meta property="og:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/saveAllAsHAR.png">
<meta property="og:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/lighthouse.png">
<meta property="og:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/showFramesPerSecond.png">
<meta property="og:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/FPSMeter.png">
<meta property="og:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/RAIL%E5%93%8D%E5%BA%94.png">
<meta property="og:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/webpagetest.png">
<meta property="og:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/FirstViewOrRepeatView.png">
<meta property="og:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/waterfallView.png">
<meta property="og:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/waterfallViewDetail.png">
<meta property="og:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/202202271746741.png">
<meta property="og:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/202202271746098.png">
<meta property="og:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/202202271807603.png">
<meta property="og:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/202202271822237.png">
<meta property="og:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/202202272007130.png">
<meta property="og:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/202202272014235.png">
<meta property="article:published_time" content="2022-04-23T11:27:04.403Z">
<meta property="article:modified_time" content="2022-04-23T11:27:47.124Z">
<meta property="article:author" content="LiLyn">
<meta property="article:tag" content="性能优化">
<meta property="article:tag" content="RAIL">
<meta property="article:tag" content="LightHouse">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/lilyn/pic/raw/master/jslearn-img/NetworkQueue.png">

<link rel="canonical" href="http://llmysnow.top/posts/8f9af1b2/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>优化1.性能优化的指标和工具 | 奇幻的梦之旅</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="奇幻的梦之旅" type="application/atom+xml">
</head>
<!--即时预加载技术，在用户点击之前预先加载页面-->
<script src="https://cdn.jsdelivr.net/gh/TRHX/CDN-for-itrhx.com@2.0.2/js/instantclick-1.2.2.js" type="module"></script>
<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>
	  <!--<a target="_blank" rel="noopener" href="https://github.com/llwodexue" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>-->
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">奇幻的梦之旅</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">http://llmysnow.top/</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://llmysnow.top/posts/8f9af1b2/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/logo.jpg">
      <meta itemprop="name" content="LiLyn">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="奇幻的梦之旅">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          优化1.性能优化的指标和工具
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-04-23 19:27:04" itemprop="dateCreated datePublished" datetime="2022-04-23T19:27:04+08:00">2022-04-23</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96/" itemprop="url" rel="index"><span itemprop="name">性能优化</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>6.1k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>6 分钟</span>
            </span>
            <div class="post-description">只要项目还在用，性能优化永远是时刻要关注的问题</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="性能指标和优化目标"><a href="#性能指标和优化目标" class="headerlink" title="性能指标和优化目标"></a>性能指标和优化目标</h2><h3 id="Network"><a href="#Network" class="headerlink" title="Network"></a>Network</h3><p><img data-src="https://gitee.com/lilyn/pic/raw/master/jslearn-img/NetworkQueue.png"></p>
<ul>
<li><p><code>Queueing</code>：资源需要经过排队才能从浏览器发出去，浏览器会对资源请求进行优先级安排，高优先级的内容先安排进行请求</p>
</li>
<li><p><code>DNS Lookup</code>：每个资源实际上有个域名，域名最终要被翻译成 IP，然后找到这个服务器</p>
</li>
<li><p><code>initial connection</code>：找到资源之后，客户端与服务器建立链接的过程</p>
</li>
<li><p><code>SSL</code>：有的网站是 <code>https</code>，为了安全性，使用了 SSL 证书，需要进行安全性验证，过程称为 SSL 写上</p>
</li>
<li><p><code>Request sent</code>：请求发送出去</p>
</li>
<li><p><code>Waiting(TTFB)</code>：发送出去请求到资源真正回来中间的等待时间，请求发出去到请求回来经历多久的时间，如果 TTFB 高的话，相当于请求发出去了，资源一直没回来，浏览器就是白屏</p>
<p>主要影响因素：后台的处理能力，服务器响应有多快；其次是资源，发送出去请求，回来到底会不会有延时</p>
</li>
<li><p><code>Content Download</code>：下载，如果蓝条越长，资源就越大，等待的时间就越长。如果本身一直在下载，后面的资源都无法加载</p>
</li>
<li><p><code>DOMContentLoaded</code>：DOM 加载完成时间</p>
</li>
<li><p><code>Load</code>：页面上所有资源加载完成时间</p>
</li>
</ul>
<p>如果 Network 内容较多，可以先把结果保存下来，右键点击空白处，<code>Save all as HAR with content</code></p>
<p><img data-src="https://gitee.com/lilyn/pic/raw/master/jslearn-img/saveAllAsHAR.png"></p>
<h3 id="Lighthouse"><a href="#Lighthouse" class="headerlink" title="Lighthouse"></a>Lighthouse</h3><p><img data-src="https://gitee.com/lilyn/pic/raw/master/jslearn-img/lighthouse.png"></p>
<p><strong>指标</strong></p>
<ul>
<li><code>Performance</code>：性能</li>
<li><code>Accessibility</code>：可访问性</li>
<li><code>Best Practices</code>：最佳实践</li>
<li><code>SEO</code>：对搜索引擎有没有做优化</li>
<li><code>Progressive Web App(PWA)</code>：渐进式应用价值，包括离线也能给客户进行访问</li>
</ul>
<p><strong>度量（Metrics）</strong></p>
<ul>
<li><code>First Contentful Paint</code>：第一个有内容的绘制出现的时间</li>
<li><code>Speed Index</code>：速度指数，速度指数标准是 4s</li>
</ul>
<h3 id="交互体验"><a href="#交互体验" class="headerlink" title="交互体验"></a>交互体验</h3><p>在 Network 里按 <code>Ctrl + Shift + P</code>，输入 <code>frame</code>，选择下图红框</p>
<p><img data-src="https://gitee.com/lilyn/pic/raw/master/jslearn-img/showFramesPerSecond.png"></p>
<p>会在左上角出现监控</p>
<p><img data-src="https://gitee.com/lilyn/pic/raw/master/jslearn-img/FPSMeter.png"></p>
<h2 id="RAIL-测量模型"><a href="#RAIL-测量模型" class="headerlink" title="RAIL 测量模型"></a>RAIL 测量模型</h2><ul>
<li>Response 响应</li>
<li>Animation 动画</li>
<li>Idle 空闲</li>
<li>Load 加载</li>
</ul>
<p><strong>响应</strong></p>
<ul>
<li>处理事件应在 50ms 以内完成</li>
<li>用户能接受最高延时是 100ms，所以所用的用户操作，必须在 100ms 内反馈（当用户进入交互到进行输入之后一直给出反馈所经历的时间）</li>
</ul>
<p><img data-src="https://gitee.com/lilyn/pic/raw/master/jslearn-img/RAIL%E5%93%8D%E5%BA%94.png"></p>
<p><strong>动画</strong></p>
<ul>
<li>每 10ms 产生一帧</li>
<li>浏览器去获取每一帧实际上也要些时间，大概是 6ms 左右</li>
</ul>
<p><strong>空闲</strong></p>
<ul>
<li>尽可能增加空闲时间</li>
<li>如果前置时间 50ms，处理时间 50ms，那用户的交互栏根本没时间去处理，用户点击后就会感觉卡住了，后面要用到的内容利用空闲时间慢慢记载即可</li>
</ul>
<p><strong>加载</strong></p>
<ul>
<li>在 5s 内完成内容加载并可以交互</li>
<li>一个层面：要完成内容加载，这 5s 不光是加载这么简单，加载完了还要解析，解析完了还要进行渲染，所有这些时间都算在内；另一个层面：使用移动设备，网络环境可能比较差，比如使用 3G</li>
</ul>
<p><strong>性能测量工具</strong></p>
<ul>
<li><code>Chrome DevTools</code>：开发调试、性能评测</li>
<li><code>Lighthouse</code>：网站整体质量评估</li>
<li><code>WebPageTest</code>：多测试地点、全面性能报告</li>
</ul>
<h2 id="WebPageTest"><a href="#WebPageTest" class="headerlink" title="WebPageTest"></a>WebPageTest</h2><blockquote>
<p>网站：<a target="_blank" rel="noopener" href="https://webpagetest.org/">WebPageTest</a></p>
</blockquote>
<p><img data-src="https://gitee.com/lilyn/pic/raw/master/jslearn-img/webpagetest.png"></p>
<ul>
<li><code>Test Loaction</code>：测试地址</li>
<li><code>Browser</code>：浏览器</li>
<li><code>Connection</code>：配置网络连接情况</li>
<li><code>Number of Tests to Run</code>：测试轮数</li>
<li><code>Repeat View</code>：结果视图，通常选择 <code>First View and Repeat View</code>，用户首次访问页面和第二次访问，通过这两个视图对比，可以看出缓存做的好不好</li>
<li><code>Capture Viedo</code>：捕捉视频，可以直观通过这个视频了解你的用户在这个指定设备访问的体验</li>
</ul>
<p><img data-src="https://gitee.com/lilyn/pic/raw/master/jslearn-img/FirstViewOrRepeatView.png"></p>
<ul>
<li><code>First Byte</code>：发出去的第一个请求，它得到响应的时间是多久，反应了后台的处理能力和网络回路的情况</li>
<li><code>Start Render</code>：首屏时间，指看到内容所需时间，而不是一直白屏</li>
<li><code>Speed Index</code>：速度指数（4s 以内）</li>
<li><code>Total Blocking Time(TBT)</code>：页面被阻塞住了，用户不能进行交互，这个时间累积有多长</li>
</ul>
<p><img data-src="https://gitee.com/lilyn/pic/raw/master/jslearn-img/waterfallView.png"></p>
<ul>
<li><code>Waterfall View</code>：点击瀑布图可以查看详细信息</li>
</ul>
<p><img data-src="https://gitee.com/lilyn/pic/raw/master/jslearn-img/waterfallViewDetail.png"></p>
<ul>
<li><code>Browser Main Thread</code>：主线程占用情况</li>
<li><code>CPU Utilization</code>：带宽、CPU 的占用情况</li>
<li>图片资源有并行同时家长，极大节约了时间</li>
<li>可能会有黄色背景的，后面标着（302），之前资源已经不再请求位置了，需要重定向才能找到真实位置，这就提示我们这个地方可以优化</li>
</ul>
<h3 id="部署-WebPageTest"><a href="#部署-WebPageTest" class="headerlink" title="部署 WebPageTest"></a>部署 WebPageTest</h3><p>Windows10 下打开 <code>Docker Desktop</code>，之后拉取镜像</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker pull webpagetest/server</span><br><span class="line">docker pull webpagetest/agent</span><br></pre></td></tr></table></figure>

<p>拉取完镜像后，就可以来运行一下</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker run -d -p 4000:80 webpagetest/server</span><br><span class="line">docker run -d -p 4001:80 --network=“host” -e “SERVER_URL=http://localhost:4000/work/” -e “LOCATION=Test” webpagetest/agent</span><br></pre></td></tr></table></figure>

<p>Windows 电脑配置到这即可使用，MacOS 还需要做一些其他配置</p>
<ul>
<li>先是做 <code>Server</code> 配置</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">mkdir wpt-mac-server</span><br><span class="line"><span class="built_in">cd</span> wpt-mac-server</span><br></pre></td></tr></table></figure>

<p><code>vim Dockerfile</code> 创建文件并对其进行编辑添加如下内容：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">FROM webpagetest/server</span><br><span class="line">ADD locations.ini /var/www/html/settings/</span><br></pre></td></tr></table></figure>

<p><code>vim locations.ini</code> 创建文件并对其进行编辑添加如下内容：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">[locations]</span><br><span class="line">1=Test_loc</span><br><span class="line">[Test_loc]</span><br><span class="line">1=Test</span><br><span class="line">label=Test Location</span><br><span class="line">group=Desktop</span><br><span class="line">[Test]</span><br><span class="line">browser=Chrome,Firefox</span><br><span class="line">label=<span class="string">&quot;Test Location&quot;</span></span><br><span class="line">connectivity=LAN</span><br></pre></td></tr></table></figure>

<p>本地 <code>build</code> 镜像</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker build -t wpt-mac-server .</span><br></pre></td></tr></table></figure>

<ul>
<li>再是做 <code>Agent</code> 配置，<code>vim Dockerfile</code> 创建文件并对其进行编辑添加如下内容：</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">FROM webpagetest/agent</span><br><span class="line">ADD script.sh /</span><br><span class="line">ENTRYPOINT /script.sh</span><br></pre></td></tr></table></figure>

<p><code>vim script.sh</code> 创建文件并对其进行编辑添加如下内容：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"><span class="built_in">set</span> -e</span><br><span class="line"><span class="keyword">if</span> [ -z <span class="string">&quot;<span class="variable">$SERVER_URL</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line"><span class="built_in">echo</span> &gt;&amp;2 <span class="string">&#x27;SERVER_URL not set&#x27;</span></span><br><span class="line"><span class="built_in">exit</span> 1</span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line"><span class="keyword">if</span> [ -z <span class="string">&quot;<span class="variable">$LOCATION</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line"><span class="built_in">echo</span> &gt;&amp;2 <span class="string">&#x27;LOCATION not set&#x27;</span></span><br><span class="line"><span class="built_in">exit</span> 1</span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line">EXTRA_ARGS=<span class="string">&quot;&quot;</span></span><br><span class="line"><span class="keyword">if</span> [ -n <span class="string">&quot;<span class="variable">$NAME</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">EXTRA_ARGS=<span class="string">&quot;<span class="variable">$EXTRA_ARGS</span> --name <span class="variable">$NAME</span>&quot;</span></span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line">python /wptagent/wptagent.py --server <span class="variable">$SERVER_URL</span> --location <span class="variable">$LOCATION</span> <span class="variable">$EXTRA_ARGS</span> --xvfb --dockerized -vvvvv --shaper none</span><br></pre></td></tr></table></figure>

<p>之后给脚本添加执行权限</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">chmod u+x script.sh</span><br></pre></td></tr></table></figure>

<p>之后本地 <code>build</code> 即可</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker build -t wpt-mac-agent .</span><br></pre></td></tr></table></figure>

<p>通过 <code>docker ps</code> 查看所有运行实例，<code>docker stop xxx</code> 即可停掉实例</p>
<h2 id="LightHouse"><a href="#LightHouse" class="headerlink" title="LightHouse"></a>LightHouse</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">npm install lighthouse@6 -g</span><br><span class="line">lighthouse http://www.bilibili.com</span><br></pre></td></tr></table></figure>

<p>使用后会打开一个浏览器进行测试，测试完浏览器会自动关闭，生成 html 输出结果生成到 <code>Printer html output written: ...</code>，将地址拷贝到浏览器即可看到测试报告内容</p>
<p>下面看一下网站的性能</p>
<ul>
<li><code>First Contentful Paint</code>：第一个有内容的绘制时间</li>
<li><code>Speed Index</code>：速度指数，页面上所有可见内容多久让用户看到</li>
<li><code>Largest Contentful Paint</code>：所有可见资源里最大那个花了多久看到</li>
<li><code>Time to Interative</code>：什么时候用户可以和你的网站进行交互</li>
</ul>
<p><img data-src="https://gitee.com/lilyn/pic/raw/master/jslearn-img/202202271746741.png"></p>
<p><code>Opportunities</code> 会提供一些优化建议</p>
<ul>
<li><code>Remove unused Javascript</code>：移除没有用到的 JS</li>
<li><code>Eliminate render-blocking resources</code>：减少渲染阻塞资源，要看下这个 JS 是否可以延迟加载</li>
</ul>
<p><img data-src="https://gitee.com/lilyn/pic/raw/master/jslearn-img/202202271746098.png"></p>
<p>如何确认某一个 JS 是不是必须的，之后增加不让加载的规则比如：<code>log*.js</code>，再重新加载，发现 <code>log*.js</code> 无法加载，再去首屏内容看是否受到影响</p>
<p><img data-src="https://gitee.com/lilyn/pic/raw/master/jslearn-img/202202271807603.png"></p>
<h2 id="使用-Chrome-DevTools-分析性能"><a href="#使用-Chrome-DevTools-分析性能" class="headerlink" title="使用 Chrome DevTools 分析性能"></a>使用 Chrome DevTools 分析性能</h2><p>Network 里每个资源都有一些属性：资源名称、大小、总耗时</p>
<ul>
<li>当后台开启压缩（<code>express</code> 使用 <code>compression</code> 中间件）就可以死对网络传输资源进行压缩</li>
<li>实际大小虽然是 1.4M，单网络传输时只有 429K，大大减少了网络传输资源的大小</li>
</ul>
<p><img data-src="https://gitee.com/lilyn/pic/raw/master/jslearn-img/202202271822237.png"></p>
<p>Performance 点击实心圆开始记录，在这个过程中页面发生的一切包括你的交互，都会被记录下来，直到你点击停止之后，这段过程中发生的一切都会出一个详细的性能报告；还有一种方式是点击刷新按钮，就会刷新我们的页面，记录页面从开始刷新一直到整个所有资源加载完成这个过程所发生的一切，然后进行性能分析</p>
<p><img data-src="https://gitee.com/lilyn/pic/raw/master/jslearn-img/202202272007130.png"></p>
<ul>
<li>Main 主线程，可以看到随着时间推移，主线程都做了哪些任务。它是自上而下类似堆栈结构，每个调用关系都清晰表示出了，比如我们做个 Task，Task 里面会有一些相关的调用，一层层把我们的调用关系都列出来，一直到最后</li>
<li>Timings 关键事件节点，<code>DCL</code> 就是 DOM 加载完成时间，它发生之前都做了什么</li>
</ul>
<p><img data-src="https://gitee.com/lilyn/pic/raw/master/jslearn-img/202202272014235.png"></p>
<p>网络吞吐：可以调整我们现在的网络状态，模拟用户网络情况</p>
<ul>
<li><code>Download</code>：4G 下载速度大概在 5~12M</li>
<li><code>Upload</code>：4G 上行速度一般是 2~5M</li>
<li><code>Latency</code>：延迟需要考虑用户所在位置的信号</li>
</ul>
<h2 id="常用性能测量-APIs"><a href="#常用性能测量-APIs" class="headerlink" title="常用性能测量 APIs"></a>常用性能测量 APIs</h2><p>性能测量工具都有一些关键的时间节点，比如：TTFB、首屏，这些时间节点是通过浏览器</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// load事件后触发</span></span><br><span class="line"><span class="built_in">window</span>.addEventListener(<span class="string">&#x27;load&#x27;</span>, <span class="function"><span class="params">e</span> =&gt;</span> &#123;</span><br><span class="line">  <span class="comment">// Time to Interactive 可交互时间</span></span><br><span class="line">  <span class="keyword">let</span> timing = performance.getEntriesByType(<span class="string">&#x27;navigation&#x27;</span>)[<span class="number">0</span>]</span><br><span class="line">  <span class="comment">// 计算 tti = domInteractive - fetchStart</span></span><br><span class="line">  <span class="keyword">let</span> tti = timing.domInteractive - timing.fetchStart</span><br><span class="line">  <span class="built_in">console</span>.log(<span class="string">&#x27;TTI&#x27;</span>, tti)</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>

<p><code>performance</code> API 一些常用时间计算规则：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// DNS 解析耗时:</span></span><br><span class="line">domainLookupEnd - domainLookupStart</span><br><span class="line"><span class="comment">// TCP 连接耗时:</span></span><br><span class="line">connectEnd - connectStart</span><br><span class="line"><span class="comment">// SSL 安全连接耗时:</span></span><br><span class="line">connectEnd - secureConnectionStart</span><br><span class="line"><span class="comment">// 网络请求耗时 (TTFB):</span></span><br><span class="line">responseStart - requestStart</span><br><span class="line"><span class="comment">// 数据传输耗时:</span></span><br><span class="line">responseEnd - responseStart</span><br><span class="line"><span class="comment">// DOM 解析耗时:</span></span><br><span class="line">domInteractive - responseEnd</span><br><span class="line"><span class="comment">// 资源加载耗时:</span></span><br><span class="line">loadEventStart - domContentLoadedEventEnd</span><br><span class="line"><span class="comment">// First Byte时间:</span></span><br><span class="line">responseStart - domainLookupStart</span><br><span class="line"><span class="comment">// 白屏时间:</span></span><br><span class="line">responseEnd - fetchStart</span><br><span class="line"><span class="comment">// 首次可交互时间:</span></span><br><span class="line">domInteractive - fetchStart</span><br><span class="line"><span class="comment">// DOM Ready 时间:</span></span><br><span class="line">domContentLoadEventEnd - fetchStart</span><br><span class="line"><span class="comment">// 页面完全加载时间:</span></span><br><span class="line">loadEventStart - fetchStart</span><br><span class="line"><span class="comment">// http 头部大小：</span></span><br><span class="line">transferSize - encodedBodySize</span><br><span class="line"><span class="comment">// 重定向次数：</span></span><br><span class="line">performance.navigation.redirectCount</span><br><span class="line"><span class="comment">// 重定向耗时:</span></span><br><span class="line">redirectEnd - redirectStart</span><br></pre></td></tr></table></figure>

<p>通过 <code>performance</code> 实时监测对象</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 通过PerformanceObserver得到所有long tasks对象</span></span><br><span class="line"><span class="keyword">let</span> observer = <span class="keyword">new</span> PerformanceObserver(<span class="function"><span class="params">list</span> =&gt;</span> &#123;</span><br><span class="line">  <span class="keyword">for</span> (<span class="keyword">const</span> entry <span class="keyword">of</span> list.getEntries()) &#123;</span><br><span class="line">    <span class="built_in">console</span>.log(entry)</span><br><span class="line">  &#125;</span><br><span class="line">&#125;)</span><br><span class="line">observer.observe(&#123; <span class="attr">entryTypes</span>: [<span class="string">&#x27;longtask&#x27;</span>] &#125;)</span><br></pre></td></tr></table></figure>

<p>加入你做的是视频网站，如果用户不再看你这个页面了，这时候需要考虑节流，不再进行视频内容的加载（可以在页面上进行 Tab 切换测试）</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> vEvent = <span class="string">&#x27;visibilitychange&#x27;</span></span><br><span class="line"><span class="keyword">if</span> (<span class="built_in">document</span>.webkitHidden !== <span class="literal">undefined</span>) &#123;</span><br><span class="line">  vEvent = <span class="string">&#x27;webkitvisibilitychange&#x27;</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">visibilityChange</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">  <span class="keyword">if</span> (<span class="built_in">document</span>.hidden || <span class="built_in">document</span>.webkitHidden) &#123;</span><br><span class="line">    <span class="built_in">document</span>.title = <span class="string">&#x27;Web page is hidden&#x27;</span></span><br><span class="line">  &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">    <span class="built_in">document</span>.title = <span class="string">&#x27;Web page is visible&#x27;</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="built_in">document</span>.addEventListener(vEvent, visibilityChange, <span class="literal">false</span>)</span><br></pre></td></tr></table></figure>

<p>如果知道用户当前网络状态，就可以有针对性资源加载。比如用户网络状态不好时使用稍微模糊的图片（去 Network 去控制网络吞吐进行测试）</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> connection = navigator.connection || navigator.mozConnection</span><br><span class="line"><span class="keyword">let</span> type = connection.effectiveType</span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">updateConnectionStatus</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">  <span class="built_in">console</span>.log(<span class="string">&#x27;connection type changed from&#x27;</span> + type + <span class="string">&#x27;to &#x27;</span> + connection.effectiveType)</span><br><span class="line">&#125;</span><br><span class="line">connection.addEventListener(<span class="string">&#x27;change&#x27;</span>, updateConnectionStatus)</span><br></pre></td></tr></table></figure>


    </div>

    
    
    

	<div>
		  
			
<div class="my_post_copyright clearfix">
  <script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>
  
  <!-- JS库 sweetalert 可修改路径 -->
  <script src="https://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script>
  <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
  <article class="box-left">
    <img src="https://gitee.com/lilyn/pic/raw/master/logo.jpg">
  </article>
  <article class="box-right">
    <p><span>本文标题:</span><a href="/posts/8f9af1b2/">优化1.性能优化的指标和工具</a></p>
    <p><span>文章作者:</span><a href="/" title="访问 LiLyn 的个人博客">LiLyn</a></p>
    <p><span>原始链接:</span><a href="/posts/8f9af1b2/" title="优化1.性能优化的指标和工具">http://llmysnow.top/posts/8f9af1b2/</a>
    <span class="copy-path"  title="点击复制文章链接"><i class="fa fa-clipboard" data-clipboard-text="http://llmysnow.top/posts/8f9af1b2/"  aria-label="复制成功！"></i></span>
  </p>
    <p><span>许可协议:</span>转载请保留原文链接及作者。</p>  
  </article>
</div>
<script> 
    var clipboard = new Clipboard('.fa-clipboard');
    $(".fa-clipboard").click(function(){
      clipboard.on('success', function(){
        swal({   
          title: "",   
          text: '复制成功',
          icon: "success", 
          showConfirmButton: true
          });
    });
    });  
</script>

		  
	</div>

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96/" rel="tag"><i class="fa fa-tag"></i> 性能优化</a>
              <a href="/tags/RAIL/" rel="tag"><i class="fa fa-tag"></i> RAIL</a>
              <a href="/tags/LightHouse/" rel="tag"><i class="fa fa-tag"></i> LightHouse</a>
          </div>
		 
		<!--post-tags 彩色标签-->
		<script type="text/javascript">
		var tagsall=document.getElementsByClassName("post-tags")
		for (var i = tagsall.length - 1; i >= 0; i--){
			var tags=tagsall[i].getElementsByTagName("a");
			for (var j = tags.length - 1; j >= 0; j--) {
				var r=Math.floor(Math.random()*75+130);
				var g=Math.floor(Math.random()*75+100);
				var b=Math.floor(Math.random()*75+80);
				tags[j].style.background = "rgb("+r+","+g+","+b+")";
				tags[j].style.color = "#fff";
				tags[j].style.padding = "0 10px";
			}
		}                        
		</script>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/posts/167dee54/" rel="prev" title="nvm 搭建 node 环境">
      <i class="fa fa-chevron-left"></i> nvm 搭建 node 环境
    </a></div>
      <div class="post-nav-item">
    <a href="/posts/9847b5b5/" rel="next" title="优化2.渲染优化">
      优化2.渲染优化 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%80%A7%E8%83%BD%E6%8C%87%E6%A0%87%E5%92%8C%E4%BC%98%E5%8C%96%E7%9B%AE%E6%A0%87"><span class="nav-text">性能指标和优化目标</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Network"><span class="nav-text">Network</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Lighthouse"><span class="nav-text">Lighthouse</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BA%A4%E4%BA%92%E4%BD%93%E9%AA%8C"><span class="nav-text">交互体验</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#RAIL-%E6%B5%8B%E9%87%8F%E6%A8%A1%E5%9E%8B"><span class="nav-text">RAIL 测量模型</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#WebPageTest"><span class="nav-text">WebPageTest</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%83%A8%E7%BD%B2-WebPageTest"><span class="nav-text">部署 WebPageTest</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#LightHouse"><span class="nav-text">LightHouse</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BD%BF%E7%94%A8-Chrome-DevTools-%E5%88%86%E6%9E%90%E6%80%A7%E8%83%BD"><span class="nav-text">使用 Chrome DevTools 分析性能</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%B8%B8%E7%94%A8%E6%80%A7%E8%83%BD%E6%B5%8B%E9%87%8F-APIs"><span class="nav-text">常用性能测量 APIs</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="LiLyn"
      src="/images/logo.jpg">
  <p class="site-author-name" itemprop="name">LiLyn</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">70</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">10</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">162</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/llwodexue" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;llwodexue" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://blog.csdn.net/qq_38689395" title="CSDN → https:&#x2F;&#x2F;blog.csdn.net&#x2F;qq_38689395" rel="noopener" target="_blank"><i class="fas fa-copyright fa-fw"></i>CSDN</a>
      </span>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title"><i class="fa fa-link fa-fw"></i>
      友情链接
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="https://scx69.gitee.io/blogs/" title="https:&#x2F;&#x2F;scx69.gitee.io&#x2F;blogs&#x2F;" rel="noopener" target="_blank">花开满城</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="http://yixin-oss.gitee.io/daytoy/" title="http:&#x2F;&#x2F;yixin-oss.gitee.io&#x2F;daytoy&#x2F;" rel="noopener" target="_blank">daytoy</a>
        </li>
    </ul>
  </div>

      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">LiLyn</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
    <span title="站点总字数">463k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">7:01</span>
</div>

<!--
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> 强力驱动
  </div>-->

<!--
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<div class="powered-by">
  <i class="fa fa-user-md"></i>
  <span id="busuanzi_container_site_pv">
    本站访问量:<span id="busuanzi_value_site_pv"></span>次
  </span>
  <span class="post-meta-divider">|</span>
  <span id="busuanzi_container_site_uv">
    本站总访客量：<span id="busuanzi_value_site_uv"></span>人
  </span>
</div>-->

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/lozad@1/dist/lozad.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  
  <script>
    (function(){
      var canonicalURL, curProtocol;
      //Get the <link> tag
      var x=document.getElementsByTagName("link");
		//Find the last canonical URL
		if(x.length > 0){
			for (i=0;i<x.length;i++){
				if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
					canonicalURL=x[i].href;
				}
			}
		}
    //Get protocol
	    if (!canonicalURL){
	    	curProtocol = window.location.protocol.split(':')[0];
	    }
	    else{
	    	curProtocol = canonicalURL.split(':')[0];
	    }
      //Get current URL if the canonical URL does not exist
	    if (!canonicalURL) canonicalURL = window.location.href;
	    //Assign script content. Replace current URL with the canonical URL
      !function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=canonicalURL,t=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === 'https')?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})();
  </script>




  
<script src="/js/local-search.js"></script>













  

  

  <!-- 动态线条背景 -->
  <script type="text/javascript" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>
  <!-- 页面点击小红心 -->
  <script type="text/javascript">
	!function(e,t,a){function n(){c(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"),o(),r()}function r(){for(var e=0;e<d.length;e++)d[e].alpha<=0?(t.body.removeChild(d[e].el),d.splice(e,1)):(d[e].y--,d[e].scale+=.004,d[e].alpha-=.013,d[e].el.style.cssText="left:"+d[e].x+"px;top:"+d[e].y+"px;opacity:"+d[e].alpha+";transform:scale("+d[e].scale+","+d[e].scale+") rotate(45deg);background:"+d[e].color+";z-index:99999");requestAnimationFrame(r)}function o(){var t="function"==typeof e.onclick&&e.onclick;e.onclick=function(e){t&&t(),i(e)}}function i(e){var a=t.createElement("div");a.className="heart",d.push({el:a,x:e.clientX-5,y:e.clientY-5,scale:1,alpha:1,color:s()}),t.body.appendChild(a)}function c(e){var a=t.createElement("style");a.type="text/css";try{a.appendChild(t.createTextNode(e))}catch(t){a.styleSheet.cssText=e}t.getElementsByTagName("head")[0].appendChild(a)}function s(){return"rgb("+~~(255*Math.random())+","+~~(255*Math.random())+","+~~(255*Math.random())+")"}var d=[];e.requestAnimationFrame=function(){return e.requestAnimationFrame||e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.oRequestAnimationFrame||e.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)}}(),n()}(window,document);
  </script>
<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"log":false,"model":{"jsonPath":"/live2dw/assets/hijiki.model.json"},"display":{"position":"right","width":150,"height":300},"mobile":{"show":true},"react":{"opacity":0.7}});</script></body>
</html>